//
//  Enemy.m
//  BeatPlane
//
//  Created by LZXuan on 15-5-6.
//  Copyright (c) 2015年 轩哥. All rights reserved.
//

#import "Enemy.h"

#define kScreenSize [UIScreen mainScreen].bounds.size
#define kEnemySpeed  2
@implementation Enemy

- (instancetype)init {
    if (self = [super init]) {
        self.image = [UIImage imageNamed:@"enemy2"];
        [self resetFrame];
    }
    return self;
}

- (void)moveDown {
    CGRect frame = self.frame;
    if (frame.origin.y >= kScreenSize.height) {
        [self resetFrame];//重置
    }else {
        frame.origin.y += kEnemySpeed;
        self.frame = frame;
    }
}

- (void)resetFrame {
    //随机产生坐标
    NSInteger sub = kScreenSize.width-50;
    //-50---- -99.0
    CGFloat y = - (arc4random()%50+50.0);
    self.frame = CGRectMake(arc4random()%sub,y, 50, 50);
}



@end
